import { NodeTypeEnum, ProcessNode } from "@src/modules/trigger/model";
import { uuid } from "@src/util/lang/string";


// 前端渲染的时候的 edge
export class ProcessEdge{
    public type: NodeTypeEnum = NodeTypeEnum.CONDITION;
    public name: string = '';
    public content: string = '';
    public children: ProcessNode[] = [];
    public uniqueId: string = uuid();
    public id?: string;
    public options: Record<string, any> = {};
    public parentNode: ProcessNode | null = null

    constructor(options: {}) {
        this.options = options
    }

}

// 服务端返回的 edge
export class TriggerEdge {
    public name?: string // 名称
    public from: string // 来源 id
    public to: string // 目标 id
    public id?: string  // 后端给的可能会没有，
    public uniqueId: string = uuid()
    public options: Record<string, any> // 给后端的配置数据 是一个对象里面的数据可能 不知道有什么

    constructor(option: TriggerEdge) {
        const { name, from, to, uniqueId, options, id } = option
        this.name = name
        this.from = from
        this.to = to
        this.id = id
        this.uniqueId = uniqueId
        this.options = options
    }
}